
<table class="table">
<thead>
	<tr>
		<td class="col-sm-1">&nbsp;</td>
		<td class="col-sm-3">Item</td>
		<td class="col-sm-2">Total Bags</td>
		<td class="col-sm-2">Total Weight</td>
		<td class="col-sm-2">Rate</td>
		<td class="col-sm-2">Amount</td>
	</tr>
</thead>
<tbody>
	<?php foreach($modelPurchaseJournalItem as $i=>$item): ?>
	<?php $totalAmount += $item->amount; ?>
	<tr rowIndex="<?php echo $i; ?>">
		<?php echo CHtml::activeHiddenField($item,"[$i]id"); ?>	
		<?php echo CHtml::activeHiddenField($item,"[$i]purchaseJournalId"); ?>	
		<td><a class="btn-sm btn btn-primary" href="javascript:void(0);"><i class="btn-deleterowpurchasejournalitem glyphicon glyphicon-remove"></i></a></td>	
		<td><?php echo CHtml::dropDownList(CHtml::activeName($item,"[$i]itemId"), $item->itemId, CHtml::listData(item::model()->findAll(), 'id', 'title'),array('class'=>'form-control')); ?></td>	
		<td><?php echo CHtml::activeTextField($item,"[$i]totalBags",array('class'=>'form-control')); ?></td>	
		<td><?php echo CHtml::activeTextField($item,"[$i]totalWeight",array('class'=>'form-control PurchaseJournalItem_totalWeight')); ?></td>	
		<td><?php echo CHtml::activeTextField($item,"[$i]rate",array('class'=>'form-control PurchaseJournalItem_rate')); ?></td>	
		<td><?php echo CHtml::activeTextField($item,"[$i]amount",array('class'=>'form-control PurchaseJournalItem_amount text-right', 'readonly'=>'true')); ?></td>	
		
	</tr>
	<?php endforeach; ?>
	<tr>
		<td colspan="5" ><b>Total</b></td>	
		<td class="text-right"><b><span id="totalAmount"><?php echo Yii::app()->format->formatNumber($totalAmount); ?></span></b></td>	
	</tr>
<tbody>
</table>